﻿Imports System.IO
Public Class IReportRong

    Private Sub IReportRong_BeforePrint(sender As Object, e As System.Drawing.Printing.PrintEventArgs) Handles Me.BeforePrint
        'xử lý lấy hình từ database
        Dim byteBLOBData As [Byte]() = New [Byte]() {}
        byteBLOBData = DirectCast(Me.ThongTinTableAdapter1.GetData.Rows(0).Item("logo"), [Byte]())
        Dim stmBLOBData As New MemoryStream(byteBLOBData)
        'gán lại vô xrpicture để hiện hình ảnh
        Me.XrPictureBox1.Image = Image.FromStream(stmBLOBData)
        'lấy dữ liệu từ db lên 
        Dim tendoanhnghiep As String = Me.ThongTinTableAdapter1.GetData().Rows(0).Item(1)
        Dim diachidoanhnghiep As String = Me.ThongTinTableAdapter1.GetData().Rows(0).Item(2)
        Dim dienthoaidoanhnghiep As String = Me.ThongTinTableAdapter1.GetData().Rows(0).Item(3)
        Dim faxdoanhnghiep As String = Me.ThongTinTableAdapter1.GetData().Rows(0).Item(4)
        'gán lại giá trị cho parameter
        Me.ThongTin.Value = tendoanhnghiep
        Me.DiaChi.Value = diachidoanhnghiep
        Me.DienThoai.Value = dienthoaidoanhnghiep
        Me.Fax.Value = faxdoanhnghiep
        'add vô report
        Me.Parameters.Add(ThongTin)
        Me.Parameters.Add(DiaChi)
        Me.Parameters.Add(DienThoai)
        Me.Parameters.Add(Fax)
    End Sub
End Class